<template>
    <view class="box">
		<view class="cu-list menu sm-border" >
			<view class="cu-item"  v-for="(item,index) in list" :key="index" >
				<view class="content padding-tb-sm">
					<view>
					
						<text class="cuIcon-homefill text-red margin-right-xs"></text> 
						{{item.houseNames}}
						
					</view>
					<view class="text-gray text-sm">
						<text class="cuIcon-infofill margin-right-xs"></text>
						<text class="text-red">客户：</text>{{item.customers}}
					</view>
					<view class="text-gray text-sm">
						<text class="cuIcon-infofill margin-right-xs"></text>
						<text class="text-red">经纪人：</text>{{item.brokers}}
					</view>
					<view class="text-gray text-sm">
						<text class="cuIcon-infofill margin-right-xs"></text>
						<text class="text-red">到访时间：</text>{{item.dateTime}}
					</view>
					<text class="text-lg" :class="item.status=='审核通过'?'text-green':'text-red'">({{item.status}})</text>
				</view>
			</view>
		</view>
		<view style="height:70upx;"></view>
		<navigator url="/pages/user/customerRecord" class="bottom">新增报备</navigator>
		<view class="cu-load load-modal" v-if="isLoading">
			<view class="cuIcon-emojifill text-orange"></view>
			<view class="gray-text">{{loadMoreDefalutText}}</view>
		</view>
		<view class="cu-load" v-if="list.length==0">
			<view class="text-gray">——————暂无数据——————</view>
		</view>
    </view>
</template>
<script>
    
    export default {
        
        data() {
            return {
                
				list:[],
				memberId:0,
                scrollInto: "",
                showTips: false,
                navigateFlag: false,
                pulling: false,
				page:1,
				isGwLeft:true,
				isLoading:false,
				connectionFailText:"正在加载"
               
            }
        },
        onLoad(e) {
			
			
        },
		onShow(e)
		{
			this.list=[];
			this.page=1;
			this.isGwLeft=true;
			uni.getStorage({
				key: 'UserInfo',
				success: (res)=>{
					if(!res.data){
						uni.showModal({
							content: '请先登陆!',
							showCancel: false
						});
						uni.navigateBack({
						}) ;
					}
					this.memberId=res.data.id;
					
					this.loadList();
					//this.user = res.data;
				},
				fail:(e)=>{
					uni.showModal({
						content: '请先登陆!',
						showCancel: false,
						success:function(){
							uni.navigateBack({
							}) ;
						}
					});
				}
			});
			
		},
		onReachBottom() {
			this.loadList();
		},
        methods: {
            //列表
            loadList() {
            	var me = this;
				if (!me.isGwLeft) {
					uni.showModal({
						content: '已经到底了!',
						showCancel: false
					});
					return;
				}
				me.isLoading=true;
            	uni.request({
            		url: me.$rootUrl+'/customerRecord/GetList',
            		data: {page:me.page,pageSize:10,memberId:me.memberId},
            		method: 'GET',
            		success(res) {
            			me.isLoading=false;
            			if (res.data.success) {
            				 me.list = me.list.concat(res.data.items);
							 
            				if (me.list.length >= res.data.total) {
            					me.isGwLeft = false;
            					
            				} else {
            					me.page++;
            				}
            			} else {
            				uni.showModal({
            					content: '服务器错误!',
            					showCancel: false
            				});
            			}
            		},
            		fail() {
						me.isLoading=false;
            			uni.showModal({
            				content: me.connectionFailText,
            				showCancel: false
            			});
            		}
            	});
            	
            },
            goDetail(e) {
                this.navigateFlag = true;
				var id=e.currentTarget.dataset.guwenid
				var url='/pages/guwen/detail?id='+id;
                uni.navigateTo({
                    url: url
                });
                setTimeout(() => {
                    this.navigateFlag = false;
                }, 200)
            }
        }
    }
</script>

<style lang="scss">
    .box{
		
		.bottom{
			position: fixed;
			bottom:0;
			background-color: #D1372C;
			padding: 8px 0;
			width:100%;
			font-size: 40upx;
			text-align: center;
			color:white;
		}
	}
</style>
